#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <vector>
#include "point.h"
#include <iostream>
#include <algorithm>
#include <cmath>
#include <ros/ros.h>
struct Kmeans_line {
  int Id_16lines = 0;     //该线所属16线中哪一条线
  int Id_alllines = 0;    //该线在所有线中的id
  double K_k;
  double K_b;
  Point_xyset Start_point;//该线段起始点的二维坐标
                          //索引，位于扫描线中第多少个点
  Point_xyset End_point;
  int Weit = 0;
};

struct Kmeans_class {
  int Class = 0;         //该线所属类别
  int Lines_num = 0;     //属于该类有几条线
  std::vector<std::vector<Kmeans_line> > detial;
};
void ke_kmeans_b(std::vector<double> &sample, int k, double min, double max,int *temp_in_cluster_b);
void ke_kmeans(std::vector<double> &sample,int k);
int k_means(int k_means,int d_means,int n_means, double **K_data);
void k_select(int k_means, double **K_data, int Lines_Num[][2], int Ground_line, std::vector<std::vector<Point_xyset> > All_Lines_Points,  Kmeans_class * Last_class);
double **K_array(int m,int n);
void freearray(double **p);
double **loadData(int *k,int *d,int *n);
double getDistance(double avector,double bvector);
void cluster();
double getDifference();
void getCenter(int in_cluster[]);
void sort_K(double Array[][7],int num);//排序，由小到大
double Angles_PI(double angle);
int round_double(double number);